package com.oyjd.ws.client.test;

import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;

public class Cmdwsimport {

	public static void main(String[] args) {

		Runtime run = Runtime.getRuntime();
		try {
			String pkg = "com.oyjd.ws.client.auto";
			String path = "N:/MyWork/MyServer/src/main/java";
			String netPath = "http://localhost:567/abc";

			// 删除旧的文件
			String delPath = path + "/" + pkg.replaceAll("\\.", "/");
			for (File f : new File(delPath).listFiles()) {
				f.delete();
			}

			String cmd = "wsimport -p " + pkg + " -d " + path + " -Xnocompile " + netPath + "?wsdl";
			Process p = run.exec("cmd.exe /c " + cmd);

			BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
			String line = null;
			StringBuilder sb = new StringBuilder();
			while ((line = br.readLine()) != null) {
				sb.append(line + "\n");
			}
			System.out.println(sb.toString());

		} catch (Exception e) {
			e.printStackTrace();
		}

	}

}
